package cn.yunhe.util;
import cn.yunhe.model.Brand;
import cn.yunhe.model.Cell;
import cn.yunhe.model.Layer;
public class LayerUtil {
    public static Layer buildLayer(int rowNum,int colNum){
        Layer layer = new Layer(rowNum,colNum);
        Brand[] brands = BrandUtil.buildBrands(layer.getCapacity());
        Cell[][] cells = layer.getCells();
        int flag = 0;
        for (int row = 0; row < cells.length; row++) {
            for (int col = 0; col < cells[row].length; col++) {
                Brand brand = brands[flag++];
                Cell cell = new Cell();
                cell.setState(1);
                cell.setBrand(brand);//把牌放到单元格
                brand.setCell(cell);//把单元格赋值给牌
                cells[row][col] = cell;
            }
        }
        return layer;
    }
}